﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// StudInfo_Control 的摘要说明
/// </summary>
public class StudInfo_Control
{
	public StudInfo_Control()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    public static DataTable getStudInfoByStudIdCard(string studIdCard)
    {
        string cmdText = "select * from StudentInfo where StudIdcard=@studIdCard";
        SqlParameter[] parms = new SqlParameter[]{
            new SqlParameter("@studIdCard",SqlDbType.VarChar,18)
        };
        parms[0].Value = studIdCard.Trim();
        return (DataTable)Dbase.GetDataTable(CommandType.Text, cmdText, parms);
    }

    public static int StudInfo_Insert(string[] insertDataValues)
    {
        return DTable.ExeInsert("StudentInfo", insertDataValues);
    }

    public static int StudInfo_Update(string[] updateDataValues, string[] keyDataValues)
    {
        return DTable.ExeUpdate("StudentInfo", updateDataValues, keyDataValues);
    }

    public static bool StudInfo_Save(string[] updateDataValues,string studIdCard)
    {
        
            if (getStudInfoByStudIdCard(studIdCard).Rows.Count > 0)
            {
                string[] keyValues = new string[] { studIdCard };
                StudInfo_Update(updateDataValues, keyValues);
            }
            else
            {
                StudInfo_Insert(updateDataValues);
            }
            return true;
        
        
    }
    
}